﻿using ConsoleApp.Infrastructure.TaskFramework;
using IPTools.Core;
using System;

namespace ConsoleApp.Job.TaskJob
{
    public class 控制台测试任务 : TaskBase
    {
        public override void Execute()
        {
            GetAreaInfoByIp();
        }

        public void GetAreaInfoByIp()
        {

        //https://www.cnblogs.com/stulzq/p/9502936.html
            ////IPTools.China
            //var ipinfoc = IpTool.Search("112.49.232.30");
            //Console.WriteLine(ipinfoc.Country); // 中国
            //Console.WriteLine(ipinfoc.Province); // 四川省
            //Console.WriteLine(ipinfoc.City); // 成都市
            //Console.WriteLine(ipinfoc.NetworkOperator);// 电信


            IpToolSettings.LoadInternationalDbToMemory = true;
            IpToolSettings.DefalutSearcherType = IpSearcherType.China;
            IpToolSettings.DefalutSearcherType = IpSearcherType.International;

            //IPTools.International
            var ipinfo = IpTool.SearchWithI18N("112.49.232.30");
            Console.WriteLine(ipinfo.Country); // 中国
            Console.WriteLine(ipinfo.CountryCode); // CN
            Console.WriteLine(ipinfo.Province); // 四川省
            Console.WriteLine(ipinfo.ProvinceCode); // SC
            Console.WriteLine(ipinfo.City); // 成都
            Console.WriteLine(ipinfo.Latitude); // 30.6667
            Console.WriteLine(ipinfo.Longitude); // 104.6667
            Console.WriteLine(ipinfo.AccuracyRadius);// 50
        }
    }
}
